package org.newtech.examples.jpa;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Column;
import javax.persistence.Table;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Transient;


@Entity
@Table(name="USER")
public class User {

    @Transient
    @PersistenceContext(unitName = "jpa")
    private static EntityManager entityManager;

    public static User find(String userid)
    {
        return entityManager.find(User.class, userid);
    }

    @Id
    @Column(name="USERID")
    private String userid;

    @Column(name="USERNAME")
    private String username;

    public String getUserid() {
        return userid;
    }

    public void setUserid(String id) {
        this.userid = userid;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public static EntityManager getEntityManager()
    {
        return entityManager;
    }

    public static void setEntityManager(EntityManager entityManager)
    {
        User.entityManager = entityManager;
    }
}

